package com.furentech.iotserver.fa.sinopec;


import com.furentech.iotserver.fa.sinopec.sinopec_processor.VerInfo;
import com.furentech.iotserver.fa.utils.FileUtils;
import com.furentech.iotserver.fa.utils.SpringUtil;

public class SinopecRestRequest {
    public static  Boolean getFuelCardAbility(String cardNum) {
        return true;
    }

    public static Boolean getWorkCardAbility(String cardNum) {
        return true;
    }

    public static Boolean isCardNumInWBList(String cardNum) {
        return true;
    }

    public static VerInfo getVerInfo() {
        VerInfo verInfo;
        verInfo=new VerInfo();

        try {

            /************************************************************************************/

            String filePathPrefix=System.getProperty("user.dir")+System.getProperty("file.separator");

            String fileName;
            fileName = filePathPrefix+"0.dat";
            byte[] verBuf = new byte[2];
            FileUtils.readFromFile(verBuf, fileName, 0, 2);


            verInfo.setBL_VER((verBuf[0] & 0x00ff) * 256 + verBuf[1]);


            /************************************************************************************/

            fileName = filePathPrefix+"1.dat";
            FileUtils.readFromFile(verBuf, fileName, 0, 2);
            verInfo.setADD_BL_VER(verBuf[1]);



            fileName = filePathPrefix+"2.dat";
            FileUtils.readFromFile(verBuf, fileName, 0, 2);
            verInfo.setDEL_BL_VER(verBuf[1]);


            fileName = filePathPrefix+"3.dat";
            FileUtils.readFromFile(verBuf, fileName, 0, 2);
            verInfo.setWH_VER(verBuf[1]);

            fileName = filePathPrefix+"4.dat";
            FileUtils.readFromFile(verBuf, fileName, 0, 2);
            verInfo.setPRC_VER(verBuf[0]);

            fileName = filePathPrefix+"5.dat";
            FileUtils.readFromFile(verBuf, fileName, 0, 2);
            verInfo.setSta_VER(verBuf[0]);

        } catch (Exception ex) {

            System.out.println("get getVerInfo exception");
            return null;
        }

        return verInfo;
    }
}
